package com.example.demo.admin.service;/**
 * Created by kete on 2017-10-30.
 */


import com.example.demo.admin.vo.UserLoginInputVo;
import com.example.demo.admin.vo.UserLoginOutputVo;
import com.example.demo.common.persistence.dao.UserMgrDao;
import com.example.demo.common.persistence.model.User;
import com.example.demo.common.vo.ShiroUser;
import com.example.demo.core.util.UserUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * 作者：kete
 * 创建时间：2017-10-30 17:51
 * 功能描述：
 * 版本：
 */
@RestController(value = "/user")
public class UserServiceImpl implements UserService {

    @Autowired
    UserMgrDao userMgrDao;


    @Override
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public UserLoginOutputVo loginSubmit(UserLoginInputVo inputVo) {

        UserLoginOutputVo outputVo = new UserLoginOutputVo();

        User user = userMgrDao.getByAccount(inputVo.getUsername());

        ShiroUser shiroUser = new ShiroUser();
        String accessToken = UserUtil.setUser(shiroUser,"");

        outputVo.setAccessToken(accessToken);
        return outputVo;
    }
}
